<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="UTF-8"%>
<%
String um,m1,m2;
um=request.getParameter("zh");
m1=request.getParameter("mm");
m2=request.getParameter("mm2");
if(m1.equals(m2)!=true){
out.println("两次密码输入不相同，请重新输入！！");
%> <a href="yhgl_zc.html">重新填写</a><%
}else{
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/test";
String username="root";
String password="root";
con=DriverManager.getConnection(url, username, password);
if(con!=null){out.println("数据库连接成功！");}
else{out.println("库连接失败！");}

String sql="insert into users(username,password) values(?,?)";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1, um);
ps.setString(2, m1);
int row=ps.executeUpdate();
if(row>0){
out.println("注册成功！");
%> <a href="yhgl_dl.html">返回登录</a><%
}
ps.close();
con.close();
}catch(ClassNotFoundException cnfe){cnfe.printStackTrace();}catch(SQLException se){se.printStackTrace();}catch(Exception e){
out.println("注册失败！");
e.printStackTrace();
}


}
%>

